package com.sskj.gocoin.p.fragment;

import com.lzy.okgo.OkGo;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.bean.HttpResponse;
import com.sskj.gocoin.m.bean.bean.Stock;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.p.base.BasePresenter;
import com.sskj.gocoin.v.fragment.ChartFragment;

import java.util.List;

/**
 * ProjectName：new_bfex
 * DESC: (类描述)
 * Created by 李岩 on 2018/7/5 0005
 * updateName:(修改人名称)
 * updateTime:(修改时间)
 * updateDesc:(修改内容)
 */
public class ChartPresenter extends BasePresenter<ChartFragment>{

    /**
     * 获取股票K线
     *
     * @param goodsType K线周期(minute/minute5/minute15/minute30/minute60/day)
     * @param code      (BCH_USDT/ETC_USDT/ETH_USDT/BTC_USDT/LTC_USDT )
     * @param page
     * @param pageSize
     */
    public void getStockInfo( String goodsType, String code, Integer page, Integer pageSize, boolean update) {
        OkGo.<HttpResponse<List<Stock>>>get(HttpConfig.BASE_URL + HttpConfig.GOODS_INFO)
                .params("goodsType", goodsType)
                .params("code", code)
                .execute(new JsonCallBack<HttpResponse<List<Stock>>>(this, false) {
                    @Override
                    public void _onSuccess(com.lzy.okgo.model.Response<HttpResponse<List<Stock>>> response) {
                        if (response.body().getCode()==200) {
                            List<Stock> stockList = response.body().getData();
                            mView.setChart(stockList, update);
                        }
                    }
                });
    }


}
